import React, { FunctionComponent } from 'react';
import {Col, Form, Row, Tabs} from 'antd';
import { createRespResult, KfBizQuickFormProps, KfFloatingContextProps, KfInput, KfQuickForm, KfTextArea } from 'kf-web-library';
import * as API from '@/services';

const FormItem = Form.Item;

type DataFormProps = {}  & KfFloatingContextProps;
const QuickForm: FunctionComponent<DataFormProps> = (props) => {
  const {  ...rest } = props;
  return (
    <KfQuickForm
      formType={'modify'}
      formProps={{
        labelCol: {
          flex: '0 0 80px',
        },
        wrapperCol: {
          flex: '1',
        },
      }}
      queryRequest={{
        modify: true,
        create: true,
      }}
      defaultQueryRequest={() => API.querySiteAboutInfo()}
      submitRequest={{
        modify: (formValues) => {
          return API.patchSiteAboutInfo({
            postCode: formValues.postCode,
            email: formValues.email,
            address: formValues.address,
            phone: formValues.phone,
            siteCopyright: formValues.siteCopyright,
          });
        },
      }}
      {...rest}
    >
      <Tabs
        defaultActiveKey="cn"
        items={[
          {
            label: '中文',
            key: 'cn',
            forceRender: true,
            children: (
              <>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.postCode.textCn)} label={"邮政编码"}  rules={[{ required: true }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.email.textCn)} label={"邮箱地址"}  rules={[{ required: true }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.address.textCn)} label={"联系地址"}  rules={[{ required: true }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.phone.textCn)} label={"联系电话"}  rules={[{ required: true }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.siteCopyright.textCn)} label={"站点版权"}  rules={[{ required: true }]}>
                  <KfInput />
                </FormItem>
              </>
            ),
          },
          {
            label: '英文',
            key: 'en',
            forceRender: true,
            children: (
              <>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.postCode.textEn)} label={"邮政编码"}  rules={[{ required: false }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.email.textEn)} label={"邮箱地址"}  rules={[{ required: false }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.address.textEn)} label={"联系地址"}  rules={[{ required: false }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.phone.textEn)} label={"联系电话"}  rules={[{ required: false }]}>
                  <KfInput />
                </FormItem>
                <FormItem name={nameof.split<API.SiteAboutInfo>((x) => x.siteCopyright.textEn)} label={"站点版权"}  rules={[{ required: false }]}>
                  <KfInput />
                </FormItem>
              </>
            ),
          },
        ]}
      />
    </KfQuickForm>
  );
};
export default QuickForm;
